package org.aaron.wbclient.utils;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import oauth.signpost.OAuthConsumer;
import oauth.signpost.http.HttpParameters;

public class OAuthUtils {

	/**
	 * 将额外的参数集合添加到OAuth Consumer对象中去
	 * 
	 * @param consumer
	 *            Consumer对象
	 * @param addtionalParams
	 *            额外的参数Map集合
	 * @return
	 */
	public static OAuthConsumer addAddtionalParametersFromMap(OAuthConsumer consumer, Map<String, String> addtionalParams) {
		Iterator<Entry<String, String>> it = addtionalParams.entrySet().iterator();
		HttpParameters httpParameters = new HttpParameters();
		while (it.hasNext()) {
			Entry<String, String> entry = it.next();
			httpParameters.put(entry.getKey(), entry.getValue());
		}
		consumer.setAdditionalParameters(httpParameters);
		return consumer;
	}
}
